<?php
namespace api\modules\v1\controllers;
use common\models\Banner;
use common\models\Article;

/*
	平台信息  公告、轮播图等
*/

class PlatformController extends CoreController
{
	/*
		文章公告列表
		* class_id  公告分类 
	*/
	public function actionArticleList()
	{
		$classId = $this->request('class_id');
		$whereArr = array();
		$whereArr['where'] = ['state' => '1'];
		if($classId) $whereArr['where']['class_id'] = $classId;

		$params = array(
			'order' => 'id desc',
			'page'  => $this->request('page', 1),
			'limit' => $this->request('page_size', 10)
		);
		$list = Article::dataList($whereArr, $params);
		$this->out('公告列表', $list);
	}

	/*
		文章详情
	*/
	public function actionArticleDetail()
	{
		if(!$id = $this->request('id')) $this->error('参数错误');
		$data = Article::getOne(['id'=>$id]);
		$this->out('文章详情', $data);
	}



	## 轮播图
	public function actionBanner()
	{
		$data = Banner::getAll([]);
		$this->out('轮播图', $data);
	}

}